// pages/newPageBankIndex/newPageBankIndex.js
var app = getApp();
var com = require('../../common.js');
Page({
  data: {
    OpeningStatus: 0,
    info: {},
    state: ''
  },
  onLoad: function (options) {
    var _this = this
    _this.onInfoPage()
    _this.onBankState()
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {},
  onInfoPage() {
    console.log(this.data)
    var _this = this
    com.link(app.link.sub, {}, function (res) {
      console.log(res)
      _this.setData({
        OpeningStatus: res.data.response.sub.state_speed,
        state: res.data.response.sub.is_public
      })
    }, 'GET')
  },
  onBankState() {
    var _this = this
    com.link(app.link.kinks, {}, function (res) {
      console.log(res)
      _this.setData({
        info: res.data.response
      })
    }, 'GET')
  },
  onOpeningTap(e) {
    var _this = this,
      id = e.currentTarget.id,
      state = _this.data.OpeningStatus,
      info = _this.data.info
    if (id == 0) {
      if (state == '000') {
        if (state == '014') {
          wx.navigateTo({
            url: '/pages/newPageBankState/newPageBankState?id=2',
          })
          return false
        }
        wx.navigateTo({
          url: '/pages/newPageBankCentent/newPageBankCentent',
        })
      }
      if (state == '002') {
        wx.navigateTo({
          url: '/pages/newPageBankCrrent/newPageBankCrrent',
        })
      }
      if (state == '004') {
        wx.navigateTo({
          url: '/pages/newPageBanthree/newPageBanthree',
        })
      }
      if (state == '006') {
        wx.navigateTo({
          url: '/pages/newPageBanfour/newPageBanfour',
        })
      }
      if (state == '010') {
        wx.showToast({
          title: '审核中',
          icon: 'none'
        })
      }
      if (state == '016') {
        wx.showModal({
          title: '温馨提示',
          content: '您的账户已冻结，请联系客服处理！'
        })
      }
      if (state == '012') {
        wx.navigateTo({
          url: '/pages/newPageBankState/newPageBankState?id=1',
        })
      }
    }
    if (id == 1) {

    }
    if (id == 2) {
      var name = _this.data.state ? info.supplier.legal_person : info.supplier.title
      wx.navigateTo({
        url: '/pages/newPageBankrecate/newPageBankrecate?name=' + name,
      })
    }
    if (id == 3) {

    }
  }
})